package com.xtianzhuang.www.controller;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.xtianzhuang.www.entity.params.WebParam;
import com.xtianzhuang.www.entity.request.base.BaseRequest;
import com.xtianzhuang.www.entity.response.base.BaseResponse;
import com.xtianzhuang.www.entity.subject.UserSubject;
import com.xtianzhuang.www.service.impl.BlindDateServiceBiz;
import com.xtianzhuang.www.service.impl.CommonServiceBiz;
import com.xtianzhuang.www.service.impl.FinanceServiceBiz;
import com.xtianzhuang.www.service.impl.PaddleOcrServiceBiz;
import com.xtianzhuang.www.service.impl.ProjectServiceBiz;
import com.xtianzhuang.www.service.impl.StudyServiceBiz;
import com.xtianzhuang.www.service.impl.SystemServiceBiz;
import com.xtianzhuang.www.service.impl.UserServiceBiz;
import com.xtianzhuang.www.service.impl.WorkServiceBiz;
import com.xtianzhuang.www.utils.SingletonFactory;

public class BaseController {
	// 当前登录主体，可获取用户身份信息、权限信息等
	protected final static UserSubject subject = SingletonFactory.getInstance(UserSubject.class);

	protected Logger logger = Logger.getLogger(getClass());

	@Autowired
	@Qualifier("projectServiceBiz")
	protected ProjectServiceBiz projectServiceBiz;

	@Autowired
	@Qualifier("userServiceBiz")
	protected UserServiceBiz userServiceBiz;

	@Autowired
	@Qualifier("financeServiceBiz")
	protected FinanceServiceBiz financeServiceBiz;
	@Autowired
	@Qualifier("workServiceBiz")
	protected WorkServiceBiz workServiceBiz;
	@Autowired
	@Qualifier("commonServiceBiz")
	protected CommonServiceBiz commonServiceBiz;
	@Autowired
	@Qualifier("systemServiceBiz")
	protected SystemServiceBiz systemServiceBiz;
	@Autowired
	@Qualifier("studyServiceBiz")
	protected StudyServiceBiz studyServiceBiz;

	@Autowired
	@Qualifier("blindDateServiceBiz")
	protected BlindDateServiceBiz blindDateServiceBiz;

	@Autowired
	@Qualifier("paddleOcrServiceBiz")
	protected PaddleOcrServiceBiz paddleOcrServiceBiz;

	@Autowired
	private WebParam webParam;


	public void executeBase(BaseRequest req, BaseResponse res) {
		if (StringUtils.isNotEmpty(webParam.getVersion())) {
			res.setVersion(webParam.getVersion());
		} else {
			res.setVersion(String.valueOf(System.currentTimeMillis()));
		}
		res.setContextPath(webParam.getContextPath());
	}
}
